package com.basics.framework.datasource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DynamicDataSourceContextHolder {
    public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
    private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal();

    public DynamicDataSourceContextHolder() {
    }

    public static void setDateSoureType(String dsType) {
        log.info("切换到{}数据源", dsType);
        CONTEXT_HOLDER.set(dsType);
    }

    public static String getDateSoureType() {
        return (String)CONTEXT_HOLDER.get();
    }

    public static void clearDateSoureType() {
        CONTEXT_HOLDER.remove();
    }
}
